{#
 # ---------------------------------------------------------------------
 #
 # GLPI - Gestionnaire Libre de Parc Informatique
 #
 # http://glpi-project.org
 #
 # @copyright 2015-2025 Teclib' and contributors.
 # @licence   https://www.gnu.org/licenses/gpl-3.0.html
 #
 # ---------------------------------------------------------------------
 #
 # LICENSE
 #
 # This file is part of GLPI.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 #
 # ---------------------------------------------------------------------
 #}

{% import 'components/form/basic_inputs_macros.html.twig' as inputs %}

{% set show_legend = show_legend|default(false) %}
{% set can_edit = has_profile_right('profile', constant('CREATE')) or has_profile_right('profile', constant('UPDATE')) or has_profile_right('profile', constant('PURGE')) %}

{% macro displayRightsMatrix(item, interface, form, group, title) %}
    {% do item.displayRightsChoiceMatrix(
        call('Profile::getRightsForForm', [interface, form, group]),
        {
            canedit: has_profile_right('profile', constant('CREATE')) or has_profile_right('profile', constant('UPDATE')) or has_profile_right('profile', constant('PURGE')),
            title: title
        }
    ) %}
{% endmacro %}

{% macro displayLifecycleMatrix(item, title, html_field, db_field, statuses) %}
    {% do item.displayLifeCycleMatrix(
        title,
        html_field,
        db_field,
        statuses,
        has_profile_right('profile', constant('CREATE')) or has_profile_right('profile', constant('UPDATE')) or has_profile_right('profile', constant('PURGE'))
    ) %}
{% endmacro %}

<div class="asset">
    {% if can_edit %}
        <form method="post" action="{{ 'Profile'|itemtype_form_path }}" data-track-changes="true">
            <input type="hidden" name="id" value="{{ item.getID() }}">
            <input type="hidden" name="_glpi_csrf_token" value="{{ csrf_token() }}">
    {% endif %}
            <div>
                <div class="card-body p-0">
                    {% block content %}{% endblock %}
                    {% if show_legend %}
                        {{ include('pages/admin/profile/legend.html.twig') }}
                    {% endif %}
                </div>
    {% if can_edit %}
                <div class="card-body mb-n5 border-top d-flex flex-row-reverse">
                    {{ inputs.submit('update', _x('button', 'Save'), 1, {
                        class: 'btn btn-primary mt-2',
                        icon: 'ti ti-device-floppy'
                    }) }}
                </div>
    {% endif %}
            </div>
    {% if can_edit %}
        </form>
    {% endif %}
</div>
